<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <meta http-equiv="X-UA-Compatible" content="ie=edge">
   <title>Document</title>
</head>
<body>
   <script>
      // 验证0-255之间的数字
      // 0-9 : \d
      // 10-99 : [1-9]\d
      // 100-199 : 1[0-9]{2}
      // 200-249 ：2[0-4]\d
      // 250-255 : 25[0-5]
      var ste =  prompt('请输入0-255之间的数字')
      var reg = /^(\d|[1-9]\d|1[0-9]{2}|2[0-4]\d|25[0-5])$/;

      // 检测
      var res = reg.test(ste);
      console.log(res);
      if(res){
         alert('ture');
      }else{
         alert('false');
      }
      
      
   </script>
</body>
</html>